package org.ccay.manage.security.service;

import java.io.Serializable;
import java.util.List;

import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;

import org.ccay.core.base.KeyValuePair;
import org.ccay.core.base.KeyValuePairVO;
import org.ccay.core.base.PageVO;
import org.ccay.core.base.PagedResult;
import org.ccay.security.annotation.SecurityBindingURL;
import org.ccay.security.annotation.SecurityOperation;
import org.ccay.security.annotation.SecurityResource;
import org.ccay.security.entity.User;
import org.ccay.security.vo.DimensionConfigVO;
import org.ccay.security.vo.ProgramVO;

@Path("/programManage")
@Produces("application/json")
@SecurityResource(code="programManage",name="系统管理|数据范围管理")
public interface IProgramManageService {
	
	@SecurityOperation(code="page",name="页面权限")
	@SecurityBindingURL("/security/program/programList.html")
	String programManage = "PROGRAM_MANAGEMENT";
	
	@POST
	@Path("/findPagedPrograms/page/{pageSize}/{curPage}")
	PagedResult<ProgramVO> findPagedPrograms(ProgramVO programVO,@PathParam("")PageVO page);
	
	/**
	 * 获取当前维度配置
	 * @return
	 */
	@GET
	@Path("/findDimensionConfigs")
	List<DimensionConfigVO> findDimensionConfigs();

	/**
	 * 获取维度值
	 * @param dimensionName
	 * @param condition
	 * @param page
	 * @return
	 */
	@GET
	@Path("/findDimensionValues/{dimensionName}/page/{pageSize}/{curPage}")
	PagedResult<KeyValuePair<? extends Serializable,String>> 
		findPagedDimensionValues(@PathParam("dimensionName") String dimensionName,@QueryParam("")KeyValuePairVO condition,@PathParam("")PageVO page);
	
    /**
     * 获取维度值
     * @param params
     */
    @POST
    @Path("/findDimensionValues/{dimensionName}")
    public List<KeyValuePair<? extends Serializable,String>> findDimensionValues(@PathParam("dimensionName") String dimensionName,List<String> keys);
	
    /**
     * 保存数据范围
     * @param programVO
     */
    @POST
    @Path("/createOrUpdateProgram")
    public void createOrUpdateProgram(ProgramVO programVO);
    
    /**
     * 查看Program
     * @param programId
     * @return
     */
    @GET
	@Path("/findDimensionValues/{programId}")
    public ProgramVO findProgram(@PathParam("programId")Long programId);
    
	/**
	 * 检查Program是否被引用
	 * @param roleId
	 * @return
	 */
	@GET
	@Path("/checkReferenced/{programId}")
	Boolean checkReferenced(@PathParam("programId")Long programId);
	
	
	/**
	 * 检查ProgramName是否存在
	 * @param roleId
	 * @return
	 */
	@GET
	@Path("/checkProgramNameUnique")
	Boolean checkProgramNameUnique(@QueryParam("programName")String programName,@QueryParam("programId")Long programId);
	
    /**
     * 级联删除Program
     * 删除Program 并删除此Program下的维度项 及此Program下的权限
     * @param programId
     * @return
     */
    @DELETE
    @Path("/deleteProgramCascade/{programId}")
    public void deleteProgramCascade(@PathParam("programId")Long programId);
}
